//
//  IdentificationVC.m
//  WalletAPP
//
//  Created by 罗弟祥 on 2019/10/9.
//  Copyright © 2019 罗弟祥. All rights reserved.
//

#import "IdentificationVC.h"
#import "IdentificationAddVC.h"
#import "NaviView.h"
#import "MyCenterModel.h"
@interface IdentificationVC ()
@property (nonatomic, retain) NaviView *naviView;
@property (nonatomic, retain) RefreshVM *vm;
@property (weak, nonatomic) IBOutlet UIView *cardBgView;
@property (weak, nonatomic) IBOutlet UILabel *nameL;
@property (weak, nonatomic) IBOutlet UILabel *cardNoL;
@property (weak, nonatomic) IBOutlet UIImageView *carBgImgV;

@end

@implementation IdentificationVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self.view addSubview:self.naviView];
    self.naviView.frame = CGRectMake(0, 0, screenW, StatusBarHeight + NavBarHeight);
    self.naviView.titStr = @"Identification";
    weakself
    [self.naviView setBackBlock:^{
        [ws.navigationController popViewControllerAnimated:YES];
    }];

    [self configViewModel];
    
}

-(void)configViewModel{
    __weak __typeof(&*self) ws = self;
    self.vm = [RefreshVM new];
    self.vm.urlStr = @"/api/identification";
    self.vm.params = [self configParam];
    self.vm.dataClass = [IdentificationModel class];
    [self.vm getRequestDataNormal];
    [self.vm setRequestResultBlock:^(id obj) {
        IdentificationModel *model = obj;
        [ws loadViewsValue:model];
    }];
}
-(NSDictionary *)configParam{
    return @{};
}

-(void)loadViewsValue:(IdentificationModel *)model{
    self.cardBgView.hidden = NO;
    self.nameL.text = model.name;
    self.cardNoL.text = model.idcard;
    [self.carBgImgV sd_setImageWithURL:[NSURL URLWithString:model.idcard_front]];
}

-(NaviView *)naviView{
    if (!_naviView) {
        _naviView = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([NaviView class]) owner:self options:nil].firstObject;
    }
    return _naviView;
}

- (IBAction)completeBtnClick:(UIButton *)sender {
    weakself
    IdentificationAddVC *vc = [IdentificationAddVC new];
    [vc setAddSuccessBlcok:^{
        [ws.vm requestDataNormal];
    }];
    [self.navigationController pushViewController:vc animated:YES];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
